package com.winit.openapi.wh.outbound.builder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.winit.oms.spi.outbound.vo.order.OutboundOrderValueAddedServiceVo;
import com.winit.oms.spi.outbound.vo.order.OutboundOrderVasAttributeVo;
import com.winit.oms.spi.vas.vo.VasOrderServiceAttributeVo;
import com.winit.oms.spi.vas.vo.VasOrderServiceSnapshotVo;


public class OutboundOrderVasBuilder {
    /**
     * 构建订单列表
     * 
     * @param vo
     * @return
     */
    public static List<Map<String, Object>> buildVasList(List<VasOrderServiceSnapshotVo> vasList) {
        List<Map<String, Object>> mapList=new ArrayList<Map<String,Object>>();
        for(VasOrderServiceSnapshotVo vo:vasList){
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("serviceCode", vo.getServiceCode());// 服务编码
            map.put("serviceName", vo.getServiceName());// 服务名称
            List<VasOrderServiceAttributeVo> attributeVos=vo.getAttributeVoList();
            if(null!=attributeVos&&attributeVos.size()>0){
                List<Map<String, Object>> attributeMapList=new ArrayList<Map<String,Object>>();
                for(VasOrderServiceAttributeVo attributeVo:attributeVos){
                    Map<String, Object> attributeMap = new HashMap<String, Object>();
                    attributeMap.put("key", attributeVo.getAttributeKey());
                    attributeMap.put("name", attributeVo.getAttributeName());
                    attributeMap.put("value", attributeVo.getAttributeValue());
                    attributeMap.put("unit", attributeVo.getUnit());
                    attributeMapList.add(attributeMap);
                }
                map.put("attributeList", attributeMapList);// 属性列表
            }
            mapList.add(map);
        }
        return mapList;
    }
    
    /**
     * 构建订单列表
     * 
     * @param vo
     * @return
     */
    public static List<Map<String, Object>> buildOutboundVasList(List<OutboundOrderValueAddedServiceVo> vasList) {
        List<Map<String, Object>> mapList=new ArrayList<Map<String,Object>>();
        for(OutboundOrderValueAddedServiceVo vo:vasList){
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("serviceCode", vo.getServiceCode());// 服务编码
            map.put("serviceName", vo.getServiceName());// 服务名称
            List<OutboundOrderVasAttributeVo> attributeVos=vo.getVasAttributeVoList();
            if(null!=attributeVos&&attributeVos.size()>0){
                List<Map<String, Object>> attributeMapList=new ArrayList<Map<String,Object>>();
                for(OutboundOrderVasAttributeVo attributeVo:attributeVos){
                    Map<String, Object> attributeMap = new HashMap<String, Object>();
                    attributeMap.put("attrCode", attributeVo.getAttributeKey());
                    attributeMap.put("attrName", attributeVo.getAttributeName());
                    attributeMap.put("attrValue", attributeVo.getAttributeValue());
                    attributeMap.put("attrUnit", attributeVo.getUnit());
                    attributeMapList.add(attributeMap);
                }
                map.put("attrList", attributeMapList);// 属性列表
            }
            mapList.add(map);
        }
        return mapList;
    }
}
